home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / basic / qbtips.lzh / QB-TIPS.TXT
Text File  |  1987-02-08  |  21KB  |  492 lines

  1.  
  2.                              Microsoft QuickBASIC Tips
  3.  
  4.                             Last Update: February 1987
  5.  
  6.                            Copyright 1986 Ford Software
  7.                      4845 Willowbend Blvd. Houston, TX 77035
  8.                                    (713) 721-5205
  9.  
  10.          This compilation of information is protected by copyright law.
  11.          Community, non-profit computer user groups may copy and distribute
  12.          this file for local (non-mail-order) members.  Any other copying
  13.          or distribution of this file is a violation of copyright law.
  14.  
  15.          Ford Software offers this information as a guide to users of
  16.          Microsoft's QuickBASIC ver. 2. We do not guarantee this informa-
  17.          tion to be correct.
  18.  
  19.          "QuickBASIC" is a trademark of Microsoft Corp.
  20.          Ford Software is not affiliated with Microsoft Corp.
  21.  
  22.          _________________________________________________________________
  23.  
  24.          The best way to use this file is to use Vern Buerg's LIST program.
  25.          (Available from the Public Software Library on disk 1-UT-274.)
  26.          LIST will let you page back and forth through the file, as well as
  27.          letting you quickly search the file for specific text.
  28.  
  29.          The subjects are arranged in alphabetical order.
  30.          _________________________________________________________________
  31.  
  32.  
  33.          8087/80287 SUPPORT
  34.  
  35.          The QuickBASIC Compiler does not internally support the 8087 or
  36.          80287 math co-processors.  Several vendors which provide libraries
  37.          that can be linked with QuickBASIC to provide co-processor
  38.          support.
  39.  
  40.          One company is Hauppauge Computer Works (516) 360-3827.  For
  41.          version 1.X and possibly version 2.00 another company that provid-
  42.          ed 8087 support for QuickBASIC was Micro Way (617) 746-7341.
  43.  
  44.          _________________________________________________________________
  45.  
  46.  
  47.          COMPATIBLES
  48.  
  49.  
  50.          Microsoft does not guarantee QB2 to run on anything but the IBM PC
  51.          and AT.  This leaves out compatibles such as the PCjr, the Compaq
  52.          80386 and any other not-quite-compatibles. This applies to your
  53.          compiled programs, as well as to the QB2 editor.
  54.  
  55.  
  56.          Toshiba 1100 Plus
  57.  
  58.          The QB2 editor's cut and paste function using the SHIFT Down Arrow
  59.          key does not work.  You can delete a single line and paste a
  60.          single line but not multiple lines.
  61.  
  62.  
  63.          Tandy 1000
  64.  
  65.          Pressing Function keys F11, F12 or Keypad keys 5,6,0 or period
  66.          cause the computer to hang when used in conjunction with the
  67.          INKEY$ statement.
  68.  
  69.          Another problem is with INPUT$(1).  Run the following program.
  70.  
  71.                 locate,,1
  72.                 main:
  73.                 a$=input$(1) : print asc(a$)
  74.                 goto main
  75.  
  76.          Press a letter key until the display is printing in the bottom row
  77.          of the screen.  Now press the keyboard keys 5 and 6
  78.          simultaneously.  Any keys pressed from this point on will be
  79.          displayed on the right-hand side of the screen.  Using INPUT$(1)
  80.          in a program that does not print to the screen causes
  81.          unpredictable results.  This is reproducible with Function keys
  82.          F11, F12 and keypad keys 0 and period.
  83.  
  84.          The CAPS and NUM LOCK keys require one key stroke to turn on and
  85.          three key strokes to turn off.
  86.  
  87.          It is perplexing that QuickBASIC 2.0 does not use the keys as they
  88.          are marked.  The Arrow, Insert, Ctrl-Break and Home keys do not
  89.          work at all.  However, Microsoft Word on the Tandy 1000 works
  90.          flawlessly.
  91.  
  92.          Microsoft has said these problems may or may not be corrected.
  93.  
  94.          QB2 does not work on the Tandy 2000, but does work on the 3000.
  95.  
  96.          _________________________________________________________________
  97.  
  98.  
  99.          COMPILING
  100.  
  101.          Switches
  102.  
  103.          QB2 creates somewhat large EXE files than QB1 or IBM Bascom2.
  104.          The following switch settings will result in file sizes roughly
  105.          equivalent to QB1:
  106.  
  107.          DEBUG OFF
  108.          MINIMIZE STRING DATA OFF
  109.          .OBJ BRUN20 (then link explicitly)
  110.          OPTIMIZE FOR SIZE
  111.  
  112.  
  113.          Creating a Batch File to Compile
  114.  
  115.          If you have program that requires complicated switches when
  116.          compiling from DOS, put the compile command in a REMark statement
  117.          at the beginning of program. Then use a program that will read
  118.          that line and create a batch file to do the compile.
  119.  
  120.  
  121.          Linking
  122.  
  123.          QuickBASIC can only be linked with other QuickBASIC subprograms
  124.          and assembly programs.  QuickBASIC can not be linked with object
  125.          modules of other languages, such as Pascal or Fortran.
  126.  
  127.  
  128.          Disk Space
  129.  
  130.          If you use QB2 to compile a program to disk and this disk is
  131.          filled up in the process, you are "hung".  Within the environment,
  132.          the keyboard is active but nothing happens - QB2 appears to be in
  133.          a loop.  When compiled externally, the message "Disk full" is
  134.          printed ad nauseum. Microsoft acknowledes this as a bug. (Infor-
  135.          mation provided by Mark Novisoff.)
  136.  
  137.          _________________________________________________________________
  138.  
  139.  
  140.          EDITOR
  141.  
  142.  
  143.          ASCII Graphics
  144.  
  145.          QB2 will not load a program if any of the first 64 bytes of the
  146.          program are upper ASCII codes (above ASCII 127). If you have upper
  147.          ASCII characters in your program, for such as drawing boxes on the
  148.          screen, make sure they are not in the first 64 characters.
  149.  
  150.  
  151.          Cut-and-Paste
  152.  
  153.          The first time a line is selected with SHIFT-UP or SHIFT-DOWN, two
  154.          lines will be selected instead of one if the cursor is not in the
  155.          first column position of the screen.
  156.  
  157.  
  158.          Overtype Mode
  159.  
  160.          QB2 does not officially have an overtype mode in the editor, but
  161.          Doug Hogarth discovered that you can force an overtype mode by
  162.          pressing the Alt-Ins keys at the same time. Be sure to experiment
  163.          with this mode before using it for real since it has some strange
  164.          side-effects.
  165.  
  166.  
  167.          Shelling to DOS
  168.  
  169.          Some people are reporting erratic results shelling to DOS. You may
  170.          need to increase your DOS environment size and set environment
  171.          variables to indicate the location of COMMAND.COM
  172.  
  173.          There is a very small default limit on environment size.  Under
  174.          DOS 3.1 and 3.2, you can increase this limit by putting this
  175.          command in your CONFIG.SYS file:
  176.  
  177.                              SHELL=\COMMAND.COM /E:nnn
  178.  
  179.          where nnn is the desired environment size.  In DOS 3.2, this is
  180.          the number of bytes.  In DOS 3.1, it is the number of paragraphs
  181.          (16 bytes).  So, for an environment size of 512 bytes, in DOS 3.1
  182.          you would say:
  183.  
  184.                              SHELL=\COMMAND.COM /E:32
  185.  
  186.          If your AUTOEXEC.BAT file loads in any stay-resident programs, you
  187.          should SET your environment variables *after* loading those
  188.          programs.  The reason is that each stay-resident program gets its
  189.          own copy of all the environment data.  It doesn't duplicate the
  190.          full possible environment size, just the amount you have actually
  191.          allocated with SET or PATH statements.  So if you put those after
  192.          the stay-resident programs, you will save memory.  (You can even
  193.          put the PATH statement after the programs, if you CD to the right
  194.          directory or call them up with an explicit path, e.g. \util\sk).
  195.          (Information provided by Michael Geary.)
  196.  
  197.  
  198.          Environment
  199.  
  200.          Tom Clark, 70320,346 on CompuServe, reports:
  201.  
  202.          I have encountered two serious (to me) bugs in QB2 when using
  203.          ENVIRON statements (see page 262 of QB2 manual).
  204.  
  205.          1. The ENVIRON statement always returns an "Out of memory" error
  206.          when trying to add a new string to the environment table.  For
  207.          example, the following 1 line program will not work unless CISE
  208.          already exists in the DOS environment table, contrary to the first
  209.          sentence in the 2nd paragraph under REMARKS on page 262: ENVIRON
  210.          "CISE=1"
  211.  
  212.          2. Contrary to the second sentence in the same paragraph, the
  213.          ENVIRON statement will not change a parameter in the DOS
  214.          environment string table.  From DOS, enter "SET CISE=9".  Then
  215.          compile the following program to a .EXE file the following
  216.          program.  Then return to DOS to run the compiled program.  The
  217.          output will look like everything is ok.  But then enter the DOS
  218.          SET command to display its environment table.  Guess what?  CISE
  219.          still equals 9.
  220.  
  221.          ...   print environ$("CISE")   ...
  222.          ...   ENVIRON "CISE=1"         ...
  223.          ...   print environ$("CISE")   ...
  224.          ...   ENVIRON "CISE=2"         ...
  225.          ...   print environ$("CISE")   ...
  226.  
  227.  
  228.          MICROSOFT replies:
  229.  
  230.          The ENVIRON$ function only operates on a local copy of the
  231.          environment table which is used when you issue a SHELL statement
  232.          in a program.  ENVIRON$ does not affect DOS's copy of the
  233.          environment table.  The local environment table size is limited to
  234.          the size it is when QB or a QB program is initiated, rounded up to
  235.          the next multiple of 16 bytes.  When a parameter is added or
  236.          lengthened, it is very easy to run out of memory.
  237.  
  238.  
  239.          Tom Clark says:
  240.  
  241.          I guess that clears up the problem, except that the QB2 manual
  242.          says nothing about a "local" table.  Under the subheading of
  243.          "ACTION," the manual says "Modifies a parameter in the DOS
  244.          environment-string table."  MicroSoft should correct this error.
  245.          However, my suggestion would be to correct the software to be
  246.          consistent with the manual.  There may still be an error in the
  247.          software.  I have already expanded the DOS environment space to
  248.          its maximum in my CONFIG.SYS via the following: SHELL=\COMMAND.COM
  249.          /P/E:62.....I'm certain that I really don't even have to expand
  250.          it, unless the presence of 11 TSRs eat up the space.  If not, it
  251.          seems to be that QB2 might not account for environment space that
  252.          exceeds the DOS default.
  253.  
  254.          _________________________________________________________________
  255.  
  256.  
  257.          ERRORS
  258.  
  259.          Subprogram Errors
  260.  
  261.          In order for a subprogram that contains an error trap to compile
  262.          without errors using QB2, you must use "RESUME" or "RESUME NEXT"
  263.          only and compile the routine with the "/X" switch.  A "RESUME
  264.          line#" causes QB2 to error (as did QB1) and not create the .OBJ
  265.          file (but QB1 would create an .OBJ file).
  266.  
  267.          Move the error routines outside the SUB.....END SUB area but in
  268.          the same source module.
  269.  
  270.          Out of Memory Errors
  271.  
  272.          If you have less than 640k, you ought to beef up your machine.
  273.          Memory is cheap.  If you have 640k, it may be that the generated
  274.          code segment is too large (bigger than 64K); and the program would
  275.          need to be split into subprograms which could be placed in a user
  276.          library or LINKed into one EXE file. In the QB2 manual, see App.D
  277.  
  278.          The program could also be split into separate EXE files and
  279.          CHAINed.  If you run out of memory at runtime, then too much data
  280.          is being used.  You get about 58000 bytes for strings, variables,
  281.          static arrays, file buffers, and constants.  In addition, each
  282.          dynamic numeric array gets its own segment of memory up to 64K.
  283.  
  284.          "Bad File Number"
  285.  
  286.          I have a program that runs fine if I compile in memory, or if I
  287.          compile from within QB into an .EXE file.  I tried the separate
  288.          compilation method, because I wanted to be able to run from a
  289.          single .EXE file, without all the USERLIB and BRUN20 junk.  When I
  290.          try to execute, I get an error, "Bad file number".
  291.               Now, the explanation of this error on p. 563 says it can
  292.          occur if a file number is "out of the range of file numbers
  293.          specified at initialization."  Ted, I can't find any way to
  294.          specify a range of file numbers at initialization.  I am familiar
  295.          with the /F switch in interpreter Basic, but I don't see any
  296.          similar facility in the QB manual.
  297.               Back to the program.  If I compile from within QB with the
  298.          OBJ(BCOM20) option, then link the file separately, I get an
  299.          "Illegal function call' when I try to execute.  Of course, I don't
  300.          have line numbers in my program, so the line number references in
  301.          the error messages just say 0.
  302.  
  303.  
  304.          Finding Errors
  305.  
  306.          If you compile from within QB2 and there is an error, QB2 will
  307.          show you what line the error is on. If you compile from DOS, it
  308.          will not show you where the error is.
  309.  
  310.  
  311.          Total Errors
  312.  
  313.          When QuickBASIC finds an error while compiling it stops code
  314.          generation and scans the remaining code for syntax errors, but no
  315.          other kinds of errors. So the number of errors shown as total
  316.          errors will not necessarily be correct.
  317.  
  318.          _________________________________________________________________
  319.  
  320.  
  321.          FILES
  322.  
  323.          Fielded Variables Zeroed Out
  324.  
  325.          Unlike other versions of BASIC, QB2 "nulls" fielded variables when
  326.          a file is closed. For example,
  327.  
  328.          10 OPEN "Testfile" AS 1 LEN=80: FIELD 1, 10 AS A$, 70 AS B$
  329.          20 GET 1,1 : PRINT A$ : PRINT B$
  330.          30 CLOSE 1 : PRINT A$ : PRINT B$
  331.  
  332.          At line 20, the values of A$ and B$ will be displayed on the
  333.          screen. At line 30, Nothing will be printed because A$ and B$ are
  334.          set to null when the CLOSE is done. To retain the values, you can
  335.          use some un-FIELDed variables. Eg: add the line:
  336.          25 A1$=A$ : B1$=B$
  337.  
  338.          _________________________________________________________________
  339.  
  340.  
  341.          MEMORY
  342.  
  343.          Quick BASIC will set a 64K code segment and a 64K data segment.
  344.          So a 128K machine cannot run programs compiled with QB2, since the
  345.          operating system will take up some memory too and not leave enough
  346.          for QB2.  Furthermore if you try to compile the programs on a 128K
  347.          machine most likely the compiler will run out of memory.  The
  348.          recommended available RAM for Quick BASIC is 256K, which is enough
  349.          for a very small program.  It is very easy to run out of memory on
  350.          a 256K machine.
  351.  
  352.          The data segment limitation is for the programs and the user
  353.          libraries, the object modules as usual are limited to 64K.
  354.          Therefore, you can include several .obj files to the user library
  355.          and they are each limited to a 64K code segment.
  356.  
  357.  
  358.          Extended Memory
  359.  
  360.          QuickBASIC does not support extended memory, but it does support
  361.          expanded memory if it follows the Lotus/Intel/Microsoft Extended
  362.          Memory Specification.  There are no special procedures involved.
  363.          It will use expanded memory as it would regular RAM.
  364.  
  365.               "Extended memory" is a term used by IBM to reference memory
  366.          at physical addresses above 1 Mb that can be accessed by an 80286
  367.          CPU.  The Lotus/Intel/Microsoft Expanded Memory Specification is a
  368.          functional definition of a bank-switched memory-expansion
  369.          subsystem.  It allows access of up to 8 Mb of memory.  This should
  370.          be transparant to QuickBASIC.
  371.  
  372.          _________________________________________________________________
  373.  
  374.  
  375.          OTHER BASICs
  376.  
  377.          Advantages of Better BASIC
  378.  
  379.          DATA: BYTE data type; POINTER variables; named constants; complex
  380.          data types, similar to C structures.
  381.  
  382.          VERBS: a complete assortment of windowing commands; DEL$ and INS$,
  383.          for deleting and inserting strings in the middle of other strings;
  384.          direct calls to BIOS or DOS; DO UNTIL as well as WHILE; DO block
  385.          structures that cannot be improperly entered or exited with a
  386.          GOTO; EXIT and EXIT n LEVELS for getting out of a block structure
  387.          neatly.
  388.  
  389.          FUNCTIONS: DRIVE$ and DIR$ that return the current drive and
  390.          directory, respectively; FREEDISK returns the number of free bytes
  391.          on a disk drive; UPPER$ and LOWER$ for case conversion; MIN, MAX,
  392.          MIN$, MAX$.
  393.  
  394.          Disadvantages of Better BASIC
  395.  
  396.          The company took 3 months to send an update, and 6 months,
  397.          (numerous phone calls, and downright nasty customer "service"
  398.          reps), to get a refund.
  399.  
  400.          _________________________________________________________________
  401.  
  402.  
  403.          SCREEN
  404.  
  405.          Apage and Vpage
  406.  
  407.          Microsoft acknowledges a problem in the handling of Apage and
  408.          Vpage in that chaning the active page parameter does not result in
  409.          a change of the active page. A fix may be made in future versions.
  410.  
  411.               Doug Hogarth (PowerSoft) 76703,374 offers this fix:
  412.  
  413.          I'm not real familiar with such uses, but if someone has ways to
  414.          check functions of the SCREEN statement apage and vpage parameters
  415.          and wants to help, I have some information.  I think that if you
  416.          use some utility to change the first occurance of 05 CD 10 in
  417.          QB.EXE to 05 90 90, and compile in memory, it might act more like
  418.          expected.  Please let me know your results whether good or bad (my
  419.          VERY limited test was okay).
  420.  
  421.  
  422.          Hercules Compatibility
  423.  
  424.          There ain't none!
  425.  
  426.  
  427.          Preventing the Screen from Clearing
  428.  
  429.          It is not possible to keep QB-compiled programs from clearing the
  430.          screen when started.  You can keep the screen from clearing in
  431.          compiled when chaining from one program to another by making sure
  432.          that you compile with the "/O" option in both programs.
  433.  
  434.  
  435.          Snow
  436.  
  437.          QB2 seems to produce a lot of snow on the IBM color graphics card.
  438.  
  439.  
  440.          Scroll Lock Status
  441.  
  442.          The Scroll Lock key and status indicator have no meaning in QB2.
  443.  
  444.          _________________________________________________________________
  445.  
  446.  
  447.          SIDEKICK AND SUPERKEY
  448.  
  449.          You must have a late version of Sidekick and Superkey to get them
  450.          to work with QB2. Call Borland Customer Support for more info
  451.          about upgrading.
  452.  
  453.          _________________________________________________________________
  454.  
  455.  
  456.          USER LIBRARY
  457.  
  458.          Using CALL ABSOLUTE
  459.  
  460.          You have to do a couple of things before running QB.  One is to
  461.          create a user library.  To do this, at the DOS prompt enter
  462.                              BUILDLIB USERLIB.OBJ
  463.          (these files are both on the QB2 distribution disk.)
  464.  
  465.          The second thing is that when you run QB, you must use the /L
  466.          switch, which loads the user library into memory.  The /L option
  467.          is only needed when compiling in memory, not if you are creating
  468.          an object file on disk.
  469.  
  470.  
  471.          Adding ASM Subroutines to a Library
  472.  
  473.          If the ASM subroutines have been made into a library using a
  474.          library manager and the library has an extension .lib then when
  475.          using BUILDLIB you can do the following: BUILDLIB /l (the /L
  476.          switch will allow you to include all the library files and build
  477.          lib is going to prompt you for their names.  If the assembler
  478.          routines are in .obj format you can also use the buildlib and make
  479.          it in to an .exe file which can be loaded as you invoke Quick
  480.          BASIC.  If the library has been created with some other library
  481.          managers, problems can be expected when using /L switch.
  482.  
  483.  
  484.          Using a User Library
  485.  
  486.          If you create a user library, all the routines in the library are
  487.          added to the program when you link.  Earlier versions of QB didn't
  488.          have user libraries, you instead explicitly linked in any .OBJ
  489.          files that you wanted to CALL.  This is still an option with QB
  490.          version 2.00.
  491.  
  492.